class SMPPAPI D2Common : public Library<D2Common>
{
#ifdef SMPPLIBRARY_EXPORT
	static void SetFunctions();
public:
	static void Init()
	{
		Name = "D2Common.dll";
		Offset = LoadDiabloLibrary();
		SetFunctions();
	}
#endif
public:
	typedef DWORD(__fastcall* TD2GetLOSDraw)(int LevelID);
	static TD2GetLOSDraw D2GetLOSDraw;
	typedef DrlgLevel* (__stdcall* TD2Get_InitLevelStructure)(DrlgMisc* pMisc,int nLevel);
	static TD2Get_InitLevelStructure D2Get_InitLevelStructure;
	typedef void(__stdcall* TD2InitLevel)(DrlgLevel* plevel);
	static TD2InitLevel D2InitLevel;
	typedef int(__stdcall* TD2GetLevelID)(DrlgRoom1* plevel);
	static TD2GetLevelID D2GetLevelID;
	typedef void(__stdcall* TD2AddRoomData)(Act* ptAct, int LevelId, int Xpos, int Ypos, UnitAny* ptPlayer);
	static TD2AddRoomData D2AddRoomData;
	typedef void(__stdcall* TD2RemoveRoomData)(Act* ptAct, int LevelId, int Xpos, int Ypos, UnitAny* ptPlayer);
	static TD2RemoveRoomData D2RemoveRoomData;
	typedef BOOL(__stdcall* TD2FindRoomForItemInInventory)(UnitInventory* pInventory, UnitAny* pCursorItem, int eInvIndex, int* pCellX, int* pCellY, int eNodePage);
	static TD2FindRoomForItemInInventory D2FindRoomForItemInInventory;
	typedef int(__stdcall* TD2CountOverlappedItems)(UnitInventory* pInventory, UnitAny* pCursorItem, int nCellX, int nCellY, int eInvIndex, int* pOverlappedCount, int* ppOverlapped, int eNodePage);
	static TD2CountOverlappedItems D2CountOverlappedItems;
	typedef DrlgRoom1* (__stdcall* TD2GetRoomFromUnit)(UnitAny* ptUnit);
	static TD2GetRoomFromUnit D2GetRoomFromUnit;

	typedef DWORD(__stdcall* TD2TestCollisionBetweenUnits)(UnitAny* pUnit1, UnitAny* pUnit2, DWORD dwCollideFlag);
	static TD2TestCollisionBetweenUnits D2TestCollisionBetweenUnits;

	typedef BOOL(__stdcall* TD2TestCollisionTowardsCoordinates)(UnitAny* pUnit, int nDestX, int nDestY, DWORD dwColMask);
	static TD2TestCollisionTowardsCoordinates D2TestCollisionTowardsCoordinates;

	typedef DWORD(__stdcall* TD2GetInventoryRecordIndex)(UnitAny* pUnit, int nPage, DWORD bLoD);
	static TD2GetInventoryRecordIndex D2GetInventoryRecordIndex;

	typedef int(__stdcall* TD2GetUnitState)(UnitAny* pUnit, DWORD StateID);
	static TD2GetUnitState D2GetUnitState;

	typedef int(__stdcall* TD2GetUnitStat)(UnitAny* pUnit, DWORD StatID, int Param);
	static TD2GetUnitStat D2GetUnitStat;

	typedef LevelTxt* (__stdcall* TD2GetLevelRecord)(int LevelID);
	static TD2GetLevelRecord D2GetLevelRecord;

	typedef ItemTxt* (__stdcall* TD2GetItemTxt)(int ItemId);
	static TD2GetItemTxt D2GetItemTxt;

	typedef ObjectTxt* (__stdcall* TD2GetObjectRecord)(DWORD nObject);
	static TD2GetObjectRecord D2GetObjectRecord;

	typedef int (__stdcall* TD2GetMinExpToLevel)(DWORD charclass, DWORD level);
	static TD2GetMinExpToLevel D2GetMinExpToLevel;
	
	typedef WORD (__stdcall* TD2GetXPos)(ObjectPath* pPath);
	static TD2GetXPos D2GetXPos;

	typedef WORD(__stdcall* TD2GetYPos)(ObjectPath* pPath);
	static TD2GetYPos D2GetYPos;

	typedef UnitAny* (__stdcall* TD2GetCursorItem)(UnitInventory* ptInventory);
	static TD2GetCursorItem D2GetCursorItem;

	typedef UnitAny* (__stdcall* TD2GetFirstInventoryItem)(UnitInventory* pInventory);
	static TD2GetFirstInventoryItem D2GetFirstInventoryItem;

	typedef UnitAny* (__stdcall* TD2GetNextInventoryItem)(UnitAny* ptLastItem);
	static TD2GetNextInventoryItem D2GetNextInventoryItem;

	typedef UnitAny* (__stdcall* TD2UnitIsItem)(UnitAny* pItem);
	static TD2UnitIsItem D2UnitIsItem;

	typedef Skill* (__stdcall* TD2GetStartSkill)(UnitAny* ptPlayer);
	static TD2GetStartSkill D2GetStartSkill;

	typedef StatsList* (__stdcall* TD2GetStateStatListByFlag)(UnitAny* pItem, DWORD Listflag);
	static TD2GetStateStatListByFlag D2GetStateStatListByFlag;

	typedef void (__fastcall* TD2UpdatePlayerState)();
	static TD2UpdatePlayerState D2UpdatePlayerState;

	typedef DWORD (__stdcall* TD2GetItemIndex)(DWORD dwItemCode);
	static TD2GetItemIndex D2GetItemIndex;

	typedef BYTE(__stdcall* TD2GetItemQuality)(UnitAny* pItem);
	static TD2GetItemQuality D2GetItemQuality;

	typedef DWORD(__stdcall* TD2TestItemFlags)(UnitAny* pItem, DWORD dwFlag, DWORD line, LPCSTR file);
	static TD2TestItemFlags D2TestItemFlags;

	typedef DWORD(__stdcall* TD2GetItemCode)(UnitAny* pItem);
	static TD2GetItemCode D2GetItemCode;

	typedef int(__stdcall* TD2CalculateRepairCost)(UnitAny* pPlayer, UnitAny* pItem, int nDiff, void* pQuestData, WORD NPCIndx, BYTE bUnk); 
	static TD2CalculateRepairCost D2CalculateRepairCost;

	typedef BOOL(__stdcall* TD2IsCorpseUseable)(UnitAny* pUnit);
	static TD2IsCorpseUseable D2IsCorpseUseable;

	typedef DWORD(__stdcall* TD2GetIndexUnicodeName)(int nUnitType, int eIndex, wchar_t* pDest);
	static TD2GetIndexUnicodeName D2GetIndexUnicodeName;

	typedef UnitAny*(__stdcall* TD2GetBackPackItemByCode)(UnitInventory* pInventory, DWORD dwItemCode, BOOL bZero);
	static TD2GetBackPackItemByCode D2GetBackPackItemByCode;

	typedef int(__stdcall* TD2IsMonsterCorpseSelectVelocity)(UnitAny* pUnit, BOOL bCheckModeDying);
	static TD2IsMonsterCorpseSelectVelocity D2IsMonsterCorpseSelectVelocity;

	static DWORD SgptDataTablesOffset;

	static DWORD* nWeaponsTxt;

	static DWORD* nArmorTxt;

#ifdef SMPPLIBRARY_EXPORT
	static DataTables* D2Common::GetDataTables();
#endif
};